From 65a5146ce5ccbf049d379a379efdfeb41c34a2b3 Mon Sep 17 00:00:00 2001 From: oliskoli Date: Mon, 27 Oct 2008 20:44:06 +0000 Subject: [PATCH] Add simple swap data filter. --- Makefile.in | 4 ++- filter_vecs.c | 6 +++++ swapdata.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 swapdata.c diff --git a/Makefile.in b/Makefile.in index 071c13f33..5bf16d6d5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -67,7 +67,7 @@ FMTS=@FMTS@ FILTERS=position.o radius.o duplicate.o arcdist.o polygon.o smplrout.o \ reverse_route.o sort.o stackfilter.o trackfilter.o discard.o \ - nukedata.o interpolate.o transform.o height.o + nukedata.o interpolate.o transform.o height.o swapdata.o JEEPS=jeeps/gpsapp.o jeeps/gpscom.o \ jeeps/gpsmath.o jeeps/gpsmem.o \ @@ -770,6 +770,8 @@ stmsdf.o: stmsdf.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ stmwpp.o: stmwpp.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h session.h csv_util.h strptime.o: strptime.c strptime.h +swapdata.o: swapdata.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ + zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h session.h filterdefs.h tef_xml.o: tef_xml.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h session.h xmlgeneric.h text.o: text.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ diff --git a/filter_vecs.c b/filter_vecs.c index 43ed5bac1..249698346 100644 --- a/filter_vecs.c +++ b/filter_vecs.c @@ -45,6 +45,7 @@ extern filter_vecs_t nuke_vecs; extern filter_vecs_t interpolatefilt_vecs; extern filter_vecs_t transform_vecs; extern filter_vecs_t height_vecs; +extern filter_vecs_t swapdata_vecs; static fl_vecs_t filter_vec_list[] = { @@ -124,6 +125,11 @@ fl_vecs_t filter_vec_list[] = { "height", "Manipulate altitudes" }, + { + &swapdata_vecs, + "swap", + "Swap latitude and longitude of all loaded points" + }, #endif { diff --git a/swapdata.c b/swapdata.c new file mode 100644 index 000000000..ddbc55e8f --- /dev/null +++ b/swapdata.c @@ -0,0 +1,72 @@ +/* + + Swap data filter + + Copyright (C) 2008 Olaf Klein, o.b.klein@gpsbabel.org + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA + + */ + +#include "defs.h" +#include "filterdefs.h" +#include + +#define MYNAME "swapdata" + +#if FILTERS_ENABLED + +static +arglist_t swapdata_args[] = { + ARG_TERMINATOR +}; + +static void +swapdata_cb(const waypoint *ref) +{ + waypoint *wpt = (waypoint *)ref; + double x; + + x = wpt->latitude; + wpt->latitude = wpt->longitude; + wpt->longitude = x; + + return; +} + +/******************************************************************************* +* %%% global callbacks called by gpsbabel main process %%% * +*******************************************************************************/ + +static void +swapdata_process(void) /* this procedure must be present in vecs */ +{ + waypt_disp_all(swapdata_cb); + route_disp_all(NULL, NULL, swapdata_cb); + track_disp_all(NULL, NULL, swapdata_cb); +} + +/*******************************************************************************/ + +filter_vecs_t swapdata_vecs = { + NULL, + swapdata_process, + NULL, + NULL, + swapdata_args +}; + +/*******************************************************************************/ +#endif // FILTERS_ENABLED -- 2.30.2